﻿(function() {
    var jasmineEnv = jasmine.getEnv();
    jasmineEnv.updateInterval = 1000;

    var htmlReporter = new jasmine.HtmlReporter();

    jasmineEnv.addReporter(htmlReporter);

    jasmineEnv.specFilter = function(spec) {
        return htmlReporter.specFilter(spec);
    };

    if (ddescribeIitSupport) {
        ddescribeIitSupport.patch(jasmineEnv);
    }

    var amdTestPath = window.amdTestPath;
    if (window.require && typeof window.require === "function" && amdTestPath !== "") {
        if (window.chutzpah) {
            window.chutzpah.usingModuleLoader = true;
        }

        requirejs.config({
            paths: {
                demo: 'app/demo'
            },
            bundles: {
                'demo/samples': ['demo/sample-y', 'demo/sample-z']
            }            
        });

        //Do cover only module on test
        _blanket.options('filter', amdTestPath.replace(/tests\/(.+)\.test/, '$1'));

        require([amdTestPath], function() {
            console.log("!!_!! Stating Jasmine from AMD callback...");
            jasmineEnv.execute();
        });
    } else {
        // If we are not running in chutzpah then run the tests onload
        if (!window.chutzpah) {
            var currentWindowOnload = window.onload;

            window.onload = function() {
                if (currentWindowOnload) {
                    currentWindowOnload();
                }

                jasmineEnv.execute();
            };
        }
    }

})();